﻿using YooAsset;

namespace UniFramework.Asset
{
    public class AssetHandleWrap
    {
        private HandleBase _handle;
        public HandleBase AssetHandle => _handle;

        public AssetHandleWrap(HandleBase handle)
        {
            _handle = handle;
        }

        public bool Release()
        {
            if (_handle == null)
            {
                return false;
            }

            if (_handle is AssetHandle)
            {
                ((AssetHandle)_handle).Release();
                return true;
            }
            else if (_handle is AllAssetsHandle)
            {
                ((AllAssetsHandle)_handle).Release();
                return true;
            }
            else if (_handle is SubAssetsHandle)
            {
                ((SubAssetsHandle)_handle).Release();
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}